package com.lam.code.configuration;

import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import com.alicp.jetcache.autoconfigure.LettuceFactory;
import com.alicp.jetcache.autoconfigure.RedisLettuceAutoConfiguration;
import io.lettuce.core.RedisClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author lam
 * @description jetcache配置
 * @date 2019/10/18 23:14
 */
//@ConditionalOnExpression("${jetcache.enabled:true}")//存在问题：若enabled为false,启动失败
@Configuration
@EnableMethodCache(basePackages = "com.lam")
@EnableCreateCacheAnnotation
public class JetCacheConfiguration {

    @Bean(name = "defaultClient")
    @DependsOn(RedisLettuceAutoConfiguration.AUTO_INIT_BEAN_NAME)
    public LettuceFactory defaultClient() {
        return new LettuceFactory("remote.default", RedisClient.class);
    }

}
